import os
import sys
import platform

OS_NAME = platform.system();
LIB_DIR=os.environ['LIB_DIR'];
BIN_DIR=os.environ['BIN_DIR'];

env=DefaultEnvironment().Clone()
SOURCES=Glob('spine2d/*.c')+Glob('*.c') + Glob('spine2d/*.cpp')

EXPORT_DEF=''
if OS_NAME == 'Windows' :
  if os.environ['TOOLS_NAME'] == '' :
    EXPORT_DEF = ' /DEF:"src/spine2d.def" '
  elif os.environ['TOOLS_NAME'] == 'mingw' :
    EXPORT_DEF = ' "src/spine2d.def" '

LIBS=['awtk', 'spine', 'glad']
if 'BUILD_SHARED' in os.environ and os.environ['BUILD_SHARED'] == 'True':
  LINKFLAGS=env['LINKFLAGS'] + EXPORT_DEF 
  env.SharedLibrary(os.path.join(BIN_DIR, 'spine2d'), SOURCES, LINKFLAGS=LINKFLAGS, LIBS=LIBS);
else:
  env.Library(os.path.join(LIB_DIR, 'spine2d'), SOURCES);

